<script setup>
import { onMounted, ref, nextTick, reactive, watch, onUpdated } from 'vue'
import axios from 'axios';
import { useEventSource } from '@vueuse/core'
const urlGo = '/go'

const { status, data, error, close } = useEventSource('https://47.92.230.95')

console.log(status.value, data.value, error.value, close.value);


const num = ref(5555)
onMounted(() => {
  nextTick(() => {
    console.log("nextTick");
  })
  num.value = 6666

  const canvas = document.getElementById('testCan');
  const ctx = canvas.getContext('2d');
  const imgUrl='http://116.204.97.29:9001/img/wz_surge_cacl_fbc1808a2_cent.png'
  const img = new Image();
  img.src = imgUrl;
  img.onload = function () {
    ctx.drawImage(img, 0, 0, 200, 200);
  }
  

})
onUpdated(() => {
  console.log("onUpdated");
})

// const promiseTick= (cb) => {
//   return Promise.resolve().then(cb);
// };

const ceshi = () => {
  axios({
    method: 'post',
    url: urlGo + '/addRemember',
    data: {
      reportName: "aaa",
      createdAt: "2021-08-09 11:11:11",
      updatedAt: "2021-08-09 11:11:11",
      IsUsing: 0,
    }
  }).then(res => {
    console.log(res);
  })
}
</script>
<template>
  <!-- {{ num }} -->
  <el-button size="default" @click="ceshi">测试</el-button>
  <canvas id="testCan" style="width: 200px;height: 200px;">
    
  </canvas>
</template> 